<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="images/reset.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<link href="images/system.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<link href="images/table_form.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<script src="{yun:}$config.sy_weburl{/yun}/js/jquery-1.8.0.min.js?v={yun:}$config.cachecode{/yun}"></script>
<link href="{yun:}$config.sy_weburl{/yun}/js/layui/css/layui.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/layui.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/phpyun_layer.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="js/admin_public.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script>
function delsingle(id,type){
	layer.confirm('删除该城市会导致有关数据无法使用，确认删除？', function(){
		$.post("index.php?m=admin_city&c=del",{delid:id,type:type,pytoken:$('#pytoken').val()},function(data){
			if(data=="1"){
				parent.layer.msg("删除成功！",2, 9,function(){location.reload();});return false;
			}else{
				parent.layer.msg("删除失败！",2, 8,function(){location.reload();});return false;
			}
		});
		return true;
	});
}
function addcity(id,type,level){
	if($(".parent"+id).attr("style")=="display:none"){
		$(".parent"+id).attr("style","display:");
		$("#img"+id).html("<a href=\"javascript:;\" onClick=\"displaycity('"+id+"','"+type+"','"+level+"');\"><img src=\"images/iconv/jian.png\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:;\" onclick=\"addson('"+id+"','"+level+"');\"class=\"admin_tj_zl\">+ 添加子类</a>");
	}else{
		$.post("index.php?m=admin_city&c=AddCity",{kid:id,type:type,pytoken:$('#pytoken').val()},function(data){
			if(data!=""){
				$("#"+id).after(data);
				$("#img"+id).html("<a href=\"javascript:;\" onClick=\"displaycity('"+id+"','"+type+"','"+level+"');\"><img src=\"images/iconv/jian.png\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:;\" onclick=\"addson('"+id+"','"+level+"');\"class=\"admin_tj_zl\">+ 添加子类</a>");
			}else{
				$("#img"+id).html("<a href=\"javascript:;\" onClick=\"displaycity('"+id+"','"+type+"','"+level+"');\"><img src=\"images/iconv/jian.png\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:;\" onclick=\"addson('"+id+"','"+level+"');\"class=\"admin_tj_zl\">+ 添加子类</a>");
			}
		});
	}
}
function displaycity(id,type,level)
{
	if(level=="parent"){
		$(".parent"+id).each(function(){
			var sonid = $(this).attr("id");
			$(".parent"+sonid).attr("style","display:none");
		});
	}
	$(".parent"+id).attr("style","display:none");
	$("#img"+id).html("<a href=\"javascript:;\" onClick=\"addcity('"+id+"','"+type+"','"+level+"');\"><img src=\"images/iconv/jia.png\" /></a>");
}
function addson(id,level){
	var html="";
	var sel="";
	if(level=="top"){
		var style="";
	}else if(level=="parent")
	{
		var style="|--------";
	}else{
		var style="|----------------";
	}
	html+='<tr align="left" id="{yun:}$city.id{/yun}" style="display:" class="parent'+id+'">';
	html+='<td class="ud"> </td>';
	html+='<td class="ud"><a href="javascript:;" onclick="javascript:this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);"><img src="images/iconv/del_icon2.gif" alt="删除当前"></a></td>';
	html+='<td class="ud">'+style+'<input class="input-text" type="text" name="addcityname_'+id+'[]" value="" /></td>';
	'{yun:}foreach from=$letter item=letter4 {/yun}'
	sel+='<option value="{yun:}$letter4{/yun}">{yun:}$letter4{/yun}</option>';
	'{yun:}/foreach{/yun}'
	html+='<td><select name="addletter_'+id+'[]">'+sel+'</select> </td>';
	html+='<td class="ud"><select name="adddisplay_'+id+'[]"><option value="1">是</option><option value="0">否</option></select></td> ';
	if(level=="parent"){
		html+='<td class="ud"><select name="addsitetype_'+id+'[]"><option value="0">否</option><option value="1">是</option></select></td> ';
	}
	html+='<td class="ud"></td>';
	html+='<td class="ud"></td></tr>';

	$("#"+id).after(html);
	$("#"+id).find("input[type='checkbox']").attr("checked", true);
	get_comindes_jobid();
}
function checkedtr(id){
	var name = $("#cityname_"+id).val();
	var c_sort = $("#citysort_"+id).val();
	var letter = $("#letter_"+id).val();
	var display = $("#display_"+id).val();
	var sitetype = $("#sitetype_"+id).val();
	if(name == "")
	{
		parent.layer.msg("城市名称不能为空！",2, 8);
		return false;
	}else{
		if(sitetype!="1")
		{
			sitetype="0";
		}
		$.post("index.php?m=admin_city&c=Single",{id:id,name:name,c_sort:c_sort,letter:letter,display:display,sitetype:sitetype,pytoken:$('#pytoken').val()},function(data){
			if(data=="2")
			{
				parent.layer.msg("城市名称不能为空！",2, 8);
			}else{
				parent.layer.msg("更新成功！",2, 9);
			}
		});
	}
}
</script>
<title>后台管理</title>
</head>
<body class="body_ifm">
<span id="temp"></span>
<div class="infoboxp">
<div class="admin_new_tip">
<a href="javascript:;" class="admin_new_tip_close"></a>
<a href="javascript:;" class="admin_new_tip_open" style="display:none;"></a>
    <div class="admin_new_tit"><i class="admin_new_tit_icon"></i>操作提示</div>
    <div class="admin_new_tip_list_cont">
      <div class="admin_new_tip_list">该页面展示了网站地区设置信息，可对地区设置编辑修改操作。</div>
       <div class="admin_new_tip_list">多城市显示只支持二级城市，增加子类需勾选父级城市！</div>
    </div>
  </div>
 
  <div class="clear"></div>
<div class="" style="margin-top:20px;">
  <div class="table-list">
    <div class="admin_table_border">
      <iframe id="supportiframe"  name="supportiframe" onload="returnmessage('supportiframe');" style="display:none"></iframe>
      <form action="index.php?m=admin_city&c=upp" method="post" target="supportiframe" id='myform'>
      <input type="hidden" id="pytoken" name="pytoken" value="{yun:}$pytoken{/yun}">
        <table width="100%">
          <thead>
            <tr class="admin_table_top">
              <th width="60" align="left">选择</th>
              <th width="160" align="left">城市排序</th>
              <th align="left">城市名称</th>
              <th align="left">关联字母</th>
              <th align="left">前台显示</th>
              <th align="left">多城市显示</th>
              <th width="180" align="left" class="admin_table_th_bg">操作</th>
            </tr>
          </thead>
          <tbody>
          {yun:}foreach item=city_row key=key  from=$city{/yun}
          <tr align="left" id="{yun:}$city_row.id{/yun}" style="display:" {yun:}if ($key+1)%2=='0'{/yun}class="admin_com_td_bg"{yun:}/if{/yun}>
            <td class="ud"><input type="checkbox" class="checkbox_all" name="checkbox_all" value="{yun:}$city_row.id{/yun}"></td>
            <td class="ud"><input type="text" name="citysort_{yun:}$city_row.id{/yun}" id="citysort_{yun:}$city_row.id{/yun}" value="{yun:}$city_row.sort{/yun}" class="input-text  citysort"></td>
            <td class="ud"><input class="input-text" type="text" id="cityname_{yun:}$city_row.id{/yun}" name="cityname_{yun:}$city_row.id{/yun}" value="{yun:}$city_row.name{/yun}" />
              <b  id="img{yun:}$city_row.id{/yun}"><a href="javascript:;" onClick="addcity('{yun:}$city_row.id{/yun}','2','parent');"><img src="images/iconv/jia.png" /></a></b></td>
            <td class="ud">
            <select id="letter_{yun:}$city_row.id{/yun}" name="letter_{yun:}$city_row.id{/yun}">
                {yun:}foreach from=$letter item=letter4 {/yun}
                <option value="{yun:}$letter4{/yun}"{yun:}if $letter4 eq $city_row.letter{/yun} selected=selected{yun:}/if{/yun}>{yun:}$letter4{/yun}</option>
                {yun:}/foreach{/yun}
            </select>
            </td>
            <td class="ud"><select id="display_{yun:}$city_row.id{/yun}" name="display_{yun:}$city_row.id{/yun}">
                <option value="1" {yun:}if $city_row.display == '1'{/yun}selected=selected{yun:}/if{/yun}>是</option>
                <option value="0" {yun:}if $city_row.display == '0'{/yun}selected=selected{yun:}/if{/yun}>否</option>
              </select>
            </td>
            <td class="ud"><font color="#FF0000"></font> </td>
            <td class="ud">
            <input class="admin_button" type="button" name="update" value="更新" onClick="checkedtr('{yun:}$city_row.id{/yun}');"/>
            
            <a href="javascript:;" onClick="delsingle('{yun:}$city_row.id{/yun}','1')" class="admin_cz_sc">删除</a></td>
          </tr>
          {yun:}/foreach{/yun}
          <tr align="left" id="0">
            <td colspan="7"><a href="javascript:;" onClick="addson('0','top');"><img src="images/iconv/jia.png" />添加顶级分类</a></td>
          </tr>
          <thead>
            <tr>
              <td width="70" colspan="1"><input type="checkbox" id="checkbox_all" name="checkbox_all" value="">
              <label for="checkbox_all">全选</label>&nbsp;
                <input type="hidden" name="id" id="hiddid_id" value="">
              </td>
              <td width="60" colspan="1"><input class="admin_button"  type="button" name="delall" onClick="return really('checkbox_all')"  value="删除选中" />
              </td>
              <td width="60" colspan="5"><input class="admin_button"  type="submit" name="updateall"   value="保存操作" />
              </td>
            </tr>
          </thead>
        </table>
      </form>
    </div>
  </div>
</div></div>
<div id="trid" style="display:none">
  <select name="letter">
    {yun:}foreach from=$letter item=letter4 {/yun}
    	<option value="{yun:}$letter4{/yun}">{yun:}$letter4{/yun}</option>
    {yun:}/foreach{/yun}
  </select>
</div>
<script>
$(document).ready(function(){
	$(".checkbox_all").click(function(){
		get_comindes_jobid();
	})
	$("#checkbox_all").click(function(){
		var checka=$("#checkbox_all").attr("checked");
		if(checka!="checked"){
			checka=false;
		}
		$(".checkbox_all").attr("checked",checka);
		get_comindes_jobid();
	})
})
function get_comindes_jobid(){
		var codewebarr="";
		$(".checkbox_all:checked").each(function(){  
			if(codewebarr==""){codewebarr=$(this).val();}else{codewebarr=codewebarr+","+$(this).val();}
		});
		$("#hiddid_id").val(codewebarr);
}
</script>
</body>
</html>